#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int maximizeSum(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());

        int sum = 0, size = nums.size();
        while (k--)
        {
            sum += nums[size - 1]++;
        }

        return sum;
    }
};

